<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|*/

$router->get('/', function () use ($router) {
    return $router->app->version();
});

// 微信登录
$router->post('/api/login', 'AuthController@login');

// 需要认证的路由组
$router->group(['middleware' => 'auth', 'prefix' => 'api'], function () use ($router) {
    // 用户信息
    $router->get('/user/profile', 'UserController@profile');
    $router->put('/user/profile', 'UserController@updateProfile');
    
    // 房间管理
    $router->post('/room/create', 'RoomController@create');
    $router->post('/room/join', 'RoomController@join');
    $router->get('/room/{id}', 'RoomController@getRoom');
    $router->put('/room/{id}/close', 'RoomController@close');
    $router->get('/user/rooms', 'RoomController@getUserRooms');
    
    // 记账相关
    $router->post('/transaction', 'TransactionController@add');
    $router->get('/room/{roomId}/transactions', 'TransactionController@getRoomTransactions');
    $router->get('/user/statistics', 'TransactionController@getUserStatistics');
    
    // 好友相关
    $router->get('/friends', 'FriendController@getFriends');
    $router->post('/friends/add', 'FriendController@addFriend');
    $router->post('/friends/accept', 'FriendController@acceptFriend');
    
    // 积分排名
    $router->get('/rankings', 'UserController@getRankings');
});

// 广告管理接口
$router->group(['prefix' => 'ad'], function () use ($router) {
    $router->get('/config', 'AdController@getConfig');
    $router->post('/track', 'AdController@trackEvent');
    $router->get('/list', 'AdController@getAds');
});

// 健康检查
$router->get('/health', function () {
    return response()->json(['status' => 'ok']);
});